"""
@file: config.py
@author: lingdubing
@time: 2024/10/25  15:40
@desc: 这是项目的基础配置文件
@character: utf-8
"""

import os

from celery import Celery
from dotenv import load_dotenv, find_dotenv
from pydantic import BaseConfig
from typing import List


class Config(BaseConfig):
    # 加载环境变量,并覆盖同名变量
    load_dotenv(find_dotenv(), override=True)
    # 调试模式
    APP_DEBUG: bool = True
    # 项目的信息
    VERSION: str = "0.0.1"
    PROJECT_NAME: str = "fsray"
    # 静态资源目录
    STATIC_DIR: str = os.path.join(os.getcwd(), "static")  # os.getcwd() 获取当前工作目录
    TEMPLATE_DIR: str = os.path.join(STATIC_DIR, "template")
    # 跨域请求
    CORS_ORIGINS: List = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List = ["*"]
    CORS_ALLOW_HEADERS: List = ["*"]
    # MYSQL配置
    MYSQL_USER: str = "root"
    MYSQL_PASSWORD: str = "lwc20051104"
    MYSQL_PORT: int = 3306
    MYSQL_IP: str = "127.0.0.1"
    MYSQL_DATABASE: str = "fsray"
    # REDIS配置
    CACHE_HOST: str = "127.0.0.1"
    CACHE_PORT: int = 6379
    # 短信服务平台配置
    MSG_USER: str = "自己账号"
    MSG_PASSWORD: str = "自己密码的md5加密值"  # 平台登录密码MD5后的值
    # 短信验证码状态
    MSGSTATUSSTR = {
        '0': '短信发送成功',
        '-1': '参数不全',
        '-2': '服务器不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间',
        '30': '密码错误',
        '40': '账号不存在',
        '41': '余额不足',
        '42': '账户已过期',
        '43': 'IP地址限制',
        '50': '内容含有敏感词',
        '51': '手机号码不正确'
    }
    # JWT配置
    JWT_SECRET_KEY = "IIOP782SDASDFFASDASDMMIIITTOOsdasddasiiooll"
    JWT_ALGORITHM = 'HS256'
    # 角色字典
    ROLE_DICT = {
        "admin": 0,
        "staff": 1,
        "user": 2
    }
    # 高德地图配置
    MAP_URL = "https://restapi.amap.com/v3/direction/driving"
    MAP_KEY = "自己key"

    # celery配置
    CELERY_APP = Celery('fsray-tasks', broker='redis://127.0.0.1:6379/0')

    CELERY_APP.conf.update(
        timezone='Asia/Shanghai',  # 时区
    )


settings = Config()
